package org.jiamandan.com.strategy.impl.car.listener;

import io.netty.channel.Channel;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jiamandan.com.constant.YxConstant;
import org.jiamandan.com.dto.YXBasicDto;
import org.jiamandan.com.strategy.impl.car.IYXContextListener;
import org.springframework.stereotype.Service;

/**
 * @version Revision 1.0.1
 * @版权：版权所有 (c) 2021
 * @author:Lee
 * @email:honvy.lee@qq.com
 * @see:
 * @创建日期：2023-03-27 11:21
 * @功能说明：
 * @begin
 * @修改记录:
 * @修改后版本 修改人        修改内容
 * @2023-03-27 11:21	         Lee        	创建
 * @end
 */
@Service(value = YxConstant.Service.CMD_15)
@AllArgsConstructor
@Slf4j
public class YxShakeHandsListener implements IYXContextListener {

    private static final int[] number = {32, 14, 2, 6, 2, 4, 4, 8, 8, 2, 2, 2, 6, 2, 2, 34, 16};

    @Override
    public void doExecute(YXBasicDto dto, Channel client) throws Exception {
        int cursor = 0, length = dto.getData().length();
        int start = 0, end = number[cursor];
        String tradeNo = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String pileNo = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String gunNo = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsVersion = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsType = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsBatteryCap = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsVol = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsFactory = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsSerialNo = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsManufactureYear = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsManufactureMonth = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsManufactureDate = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsChargeTimes = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsIdentification = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String reserved = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsCardVin = StringUtils.substring(dto.getData(), start, end);
        start = end;
        end += number[++cursor];
        String bmsSoftVersion = StringUtils.substring(dto.getData(), start, end);
    }
}
